#pragma once

#include "msli/entities/Point.hpp"
#include <cmath>

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<typename T>
class CalCirclePos {
public:
    DIS_TYPE dis_upper{};
    DIS_TYPE dis_lower{};
    /* 
     *  1 ：外切+外离
     *  2 ：相交
     *  3 ：内含
     */
    unsigned label{};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*
     * @refPt: 参考点,表示一个圆的圆心
     * @radius_refPt: 参考点所代表圆的半径
     * @queryPt: 查询点, 表示第二个圆的圆心
     * @radius_queryPt: 查询点所代表圆的半径
     */
    CalCirclePos(Point<T> &refPt, double radius_refPt, Point<T> &queryPt, double radius_queryPt) {
        double distance = queryPt.distance(refPt);
        // 外切+外离
        if (distance >= radius_refPt + radius_queryPt) {
            this->label = 1;
            this->dis_lower = 0x3f3f3f;
            this->dis_upper = 0x3f3f3f;
        } else if (distance >= fabs(radius_refPt - radius_queryPt)) {
            this->label = 2;
            if (distance > radius_queryPt) {
                this->dis_upper = radius_refPt;
                this->dis_lower = distance - radius_queryPt;
            } else {
                this->dis_lower = 0.0;
                this->dis_upper = radius_refPt;
            }
        } else {
            this->label = 3;
            if (distance > radius_queryPt) {
                this->dis_lower = distance - radius_queryPt;
                this->dis_upper = distance + radius_queryPt;
            } else {
                this->dis_upper = distance + radius_queryPt;
                this->dis_lower = 0.0;
            }
        }
    }
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
